import React from 'react'
import { Navigate, useLocation } from 'react-router-dom'

const RouterGuard = ({ children }) => {
    const location = useLocation()

    // 这里可以添加路由守卫逻辑，比如权限验证
    const isAuthenticated = true // 示例：验证用户是否登录

    if (!isAuthenticated) {
        return <Navigate to="/login" state={{ from: location }} replace />
    }

    return children
}

export default RouterGuard 